@extends('web.master')
@section('title','套餐兑换')
@section('head')
    <style>
        .dhm.shake{
            background: url(/web/images/yh.png) no-repeat center;
            background-size: cover
        }

        .dhm{
            /*text-align: center;*/
        }
        .dhm input{
            display: block;
            height: 44px;
            line-height: 44px;
            border: 1px solid #fff;
            width: 60%;
            margin: 0 auto;
            border-radius: 2px;
            margin-bottom: 20px;
            text-indent: 1em;
        }
        .line span{
            display: block;
            font-size: 25px;
            color:red;

            text-align: center;
            margin: 0 auto;

            margin-bottom: 20px;
            text-indent: 1em;
        }
    </style>
    @endsection
@section('content')

    <div class="dhm shake courses">

        <div class="btn">
            <input name="code" id="code" type="text" placeholder="请输入兑换码"/>

            <a href="javascript:void(0)" onclick="submit()">
                立即兑换
            </a>
            <div class="line">
                <span>请仔细阅读公众号推送的</span>
                <span>使用说明以及景点地图</span>

            </div>
        </div>
    </div>

@endsection
@section('foot')
    <script src="{{asset('statics/js/layer/layer_mobile/layer.js')}}" type="text/javascript" charset="utf-8"></script>
    <script>

       function submit(){
           layer.open({type: 2});
           var code= $("#code").val();
           if(code==''){
               layer.closeAll();
               layer.open({
                   content: '请输入兑换码'
                   ,skin: 'msg'
                   ,time: 2 //2秒后自动关闭
               });
       return ;
           }
           $.post('{{route('exchange')}}',{'code':code},function (response) {

               layer.closeAll();
               if(response.code=='error'){
                   layer.open({
                       content: response.msg
                       ,skin: 'msg'
                       ,time: 2 //2秒后自动关闭
                   });
               }
               if(response.code=='success'){
                   layer.open({
                       title: [
                           '兑换成功,请长按图片关注公众号',
                           'background-color: #5d93f7'
                       ]
                       ,content: '<img src="/images/guanzhu.png" >'
                   });

                  /* layer.open({
                       content:
                       ,btn: ['确定', '取消']
                       ,yes: function(index){
                           alert(response.url);

                           layer.close(index);
                       }
                   });*/
               }

           });
       }


    </script>
    @endsection